<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 代理商信息操作</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight"> 
      <div class="row">
      <form method="post" class="form-horizontal" action="" id="Myform" enctype="multipart/form-data" >
          <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <div class="form-group">
                         <input type="hidden" name="id" value="{$v}">
                            <label class="col-sm-2 control-label">{:lang('请输入密码')}</label>
                            <div class="col-sm-10">
                                <input id="password" name="password" class="form-control" required="required" placeholder="{:lang('请输入新密码')}" type="password">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" >{:lang('确认密码')}</label>
                            <div class="col-sm-10">
                                <input id="surepassword" name="surepassword" required="required" class="form-control" placeholder="{:lang('请输入确认密码')}" type="password" >
                            </div>
                        </div>
                         <div class="hr-line-dashed"></div>
                        
                    </div>
                </div>
            </div>
        </div>
        <div class="row"  style="margin-top: 23px;">
            <div class="center-block col-sm-2">
                <button type="button" class="btn btn-primary btn-block" id="submit">{:lang('提交')} </button>
            </div>      
        </div>
        </form>
    </div>
    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/content.min.js?v=1.0.0"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
    <script type="text/javascript">
    //更新信息
    $('#submit').click(function(){
            var formdata = $('#Myform').serialize();
            var pass = $('#password').val();
            var surpass = $('#surepassword').val();
            if(pass==''){
                layer.msg("{:lang('请输入初始密码')}", {icon: 2});
                $('#password').placeholder("{:lang('请输入初始密码')}");
                $('#password').focus();
                return false;
            }
            if(pass.length<6){
                layer.msg("{:lang('请输入6位以上的密码')}", {icon: 2});
                $('#password').focus();
                return false;
            }
            if(surpass==''){
                layer.msg("{:lang('请输入确认密码')}", {icon: 2});
                $('#surepassword').placeholder("{:lang('请输入确认密码')}");
                $('#surepassword').focus();
                return false;
            }
            if(surpass.length<6){
                 layer.msg("{:lang('请输入6位以上的密码')}", {icon: 2});
                $('#surepassword').placeholder("{:lang('请输入6位以上的密码')}");
                $('#surepassword').focus();
                return false;
            }
            if(pass != surpass ){
                layer.msg("{:lang('密码不一致,请重新输入')}", {icon: 2});
                $('#password').placeholder("{:lang('密码不一致,请重新输入')}");
                $('#surepassword').placeholder("{:lang('密码不一致,请重新输入')}");
                $('#password').focus();
                $('#surepassword').focus();
                return false;
            }
            $.ajax({
                type : 'POST',
                url  : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Operator/editadmin',
                dataType : 'json',
                data : formdata,
                async : false,
                success : function(result){
                    if(0 == result.code){
                        layer.msg(result.msg, {icon: 1});
                        parent.location.reload();
                    }else{
                        layer.msg(result.msg, {icon: 5});
                    }
                },
                error : function(){
                    layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                }
            })
        });
  </script>

</body>

</html>